function main(input) {
  try {
    // 接口返回数据：{ code, message, data, bizType }
    const wrapper = JSON.parse(input.originalData) || { data: [], bizType: '' };
    // 日历：展示沈阳市这个月的空气质量日历
    if (wrapper.bizType == 'calendar') {
      const resData = wrapper.data || [];
      const calendarData = [
        {
          type: 'component',
          component: 'Calendar',
          data: resData,
          extraData: { selectYear: resData.map(item => item.year) },
        }
      ];
      return {
        type: 'chartType',
        data: JSON.stringify(calendarData),
      };
    }
    // 默认：浓度趋势变化
    const originalDataFinal = wrapper.data[0] || [];
    // 获取时间轴并计算长度
    const xData = originalDataFinal.dataTime || [];
    const maxLength = xData.length;
    // 创建带长度参数的系列项
    const createItem = (name, data) => {
      return {
        name,
        type: 'line',
        data: Array.isArray(data)
          ? data.slice(0, maxLength).map(v => typeof v === 'number' ? v : null)
          : new Array(maxLength).fill(null),
      };
    };
    const echartData = [{
      type: 'echarts',
      data: {
        ...createChartOption(
          xData,
          [
            createItem('PM₂.₅', originalDataFinal.pm25),
            createItem('PM₁₀', originalDataFinal.pm10),
            createItem('O₃', originalDataFinal.o3),
            createItem('NO₂', originalDataFinal.no2),
            createItem('SO₂', originalDataFinal.so2),
            createItem('CO', originalDataFinal.co),
          ],
        ),
      },
    }];
    return {
      type: 'chartType',
      data: JSON.stringify(echartData),
    };
  } catch (e) {
    console.error('转换失败:', e);
    return { siteContent: { ...createChartOption([], []) } };
  }
}

function createChartOption(xData, seriesData) {
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985',
          precision: 0,
        },
      },
    },
    legend: {
      top: '10px',
      textStyle: {
        color: '#fff',
      },
    },
    toolbox: {
      show: false,
      feature: {
        saveAsImage: {},
      },
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: xData,
        // 设置字体倾斜
        axisLabel: {
          rotate: 0,
          color: '#fff',
        },
        nameTextStyle: {
          color: '#fff',
        },
      },
    ],
    yAxis: [
      {
        // type: 'log',
        min: 1,
        axisLine: {
          show: 1 == 1,
          lineStyle: {
            width: 1,
            color: '#999',
          },
        },
        axisTick: {
          show: 1 == 1,
          lineStyle: {
            color: '#fff',
          },
        },
        axisLabel: {
          color: '#fff',
        },
        // logBase: 5,
        // minInterval: 1
      },
    ],
    series: seriesData,
    color: ['#0096FF', '#27CB75 '],
    dataZoom: [
      {
        id: 'main',
        type: 'inside',
        xAxisIndex: [0],
        filterMode: 'none',
        start: 0,
        end: 100,
      },
    ],
  };
}
